﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SmallERP.Bll.PinBan;
using SmallERP.MODEL.FoundationModel;
using System.Collections;


namespace SmallERP.MakeBigPic.Forms
{
    public partial class FrmSetting : Form
    {
        List<string> SelectedPrinterIdList = new List<string>();
        List<Printer_info> _printerList = new List<Printer_info>();
        public FrmSetting()
        {
            InitializeComponent();
        }

        private void FrmSetting_Load(object sender, EventArgs e)
        {
            //_printerList = PrinterBLL.GetAllPrinters();
            ////_printerList.Add(new Printer_info()
            ////{
            ////    PName = "全部",
            ////    PrinterID = -1
            ////});
            //checkedListBox1.DataSource = _printerList;
            //checkedListBox1.DisplayMember = "PName";
            //checkedListBox1.ValueMember = "PrinterID";

            #region 设置初始值

            //List<string> printNameList = Properties.Settings.Default.PrinterIdList;
            //if (printNameList != null && printNameList.Count > 0)
            //{
            //    foreach (string PrinterName in printNameList)
            //    {
            //        for (int i = 0; i < checkedListBox1.Items.Count; i++)
            //        {
            //            if (checkedListBox1.Items[0].ToString() == PrinterName)
            //            {
            //                checkedListBox1.SetItemChecked(i, true);
            //                break;
            //            }
            //        }

            //    }
            //}

            //else//还未设置
            //{

            //}
            if (Properties.Settings.Default.BarCodeFontSize <= 0)
            {
                spinEdit1.Value = 50;
            }
            else
            {
                spinEdit1.Value = Properties.Settings.Default.BarCodeFontSize;
            }
            checkBox2.Checked = Properties.Settings.Default.BarCodeFontIsBold;
            chkAddICCByPS.Checked = Properties.Settings.Default.AddIccByPs;
            spinEditCodeHeight.Value = Properties.Settings.Default.CodeHeight;
            checkBoxIsBoardInfo.Checked = Properties.Settings.Default.IsPrintBoardInfo;
            checkBoxIsprintLine.Checked = Properties.Settings.Default.IsPrintLine;
            #endregion
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            //SelectedPrinterIdList.Clear();
            //foreach (var item in checkedListBox1.CheckedItems)
            //{
            //    SelectedPrinterIdList.Add(item.ToString());
            //}
            //Properties.Settings.Default.PrinterIdList = SelectedPrinterIdList;
            Properties.Settings.Default.BarCodeFontSize = (int)spinEdit1.Value;
            Properties.Settings.Default.BarCodeFontIsBold = checkBox2.Checked;
            Properties.Settings.Default.AddIccByPs = chkAddICCByPS.Checked;
            Properties.Settings.Default.CodeHeight = (int)spinEditCodeHeight.Value;
            Properties.Settings.Default.IsPrintBoardInfo = checkBoxIsBoardInfo.Checked;
            Properties.Settings.Default.IsPrintLine = checkBoxIsprintLine.Checked;
            try
            {
                Properties.Settings.Default.Save();
            }
            catch (Exception)
            {
                
                throw;
            }
            MessageBox.Show("保存成功");

            this.Close();
           
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            this.Close();
        }


    }
}
